package com.yl.chainStore.test

import com.alibaba.fastjson.JSONArray
import com.alibaba.fastjson.JSONObject
import com.baomidou.mybatisplus.core.toolkit.IdWorker
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.yl.chainStore.control.BaseCtrl
import com.yl.common.ErrorCode
import com.yl.common.control.ResponseBody
import com.yl.common.control.returnError
import com.yl.common.control.returnSuccess
import com.yl.common.getContext
import com.yl.users.entity.CompanyRole
import com.yl.users.services.ICompanyRoleService
import com.yl.users.services.ICompanyUserService
import org.springframework.transaction.annotation.Transactional
import org.springframework.transaction.interceptor.TransactionAspectSupport
import org.springframework.web.bind.annotation.*

/**
 * 公司角色管理
 */
@RestController
@RequestMapping("api/user/")
open class UserTest(
) : BaseCtrl() {

    @PostMapping("login")
     open fun rolePage(@RequestBody body: JSONObject): ResponseBody {
         val loginName = body.getString("loginName")
         val password = body.getString("password")

        return if(loginName == "login" && password == "pass"){
            returnSuccess(JSONObject().apply {
                put("id",3)
                put("name","测试用户")
                put("power",JSONArray().apply {
                    JSONObject().apply {
                        put("name","abc")
                    }
                    JSONObject().apply {
                        put("name","ad33333")
                    }
                })
            })
        }else returnError(ErrorCode.LOGIN_ERROR)
    }
}
